package com.woniuxy.dao.impl;

import com.woniuxy.dao.StuDao;
import com.woniuxy.entity.Stu;

import java.util.List;

/**
 * @author 作者
 * @create 2025-11-19 14:48
 */
public class StuDaoImpl implements StuDao {
    @Override
    public void insert(Stu stu) throws Exception {
        JdbcUtils.executeUpdate(
                "insert into stu values(?,?,?,?)",
                stu.getSid(),stu.getSname(),stu.getPwd(),stu.getAge());

    }

    @Override
    public void update(Stu stu) throws Exception {
        JdbcUtils.executeUpdate("update stu set sname=?,pwd=?,age=? where sid=?",
                stu.getSname(),stu.getPwd(),stu.getAge(),stu.getSid());
    }

    @Override
    public void deleteBySid(int sid) throws Exception {
        JdbcUtils.executeUpdate("delete from stu where sid=?", sid);
    }

    @Override
    public List<Stu> selectAll() throws Exception {
        return  JdbcUtils.executeQueryList(Stu.class, "select * from stu");
    }
}
